import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * User: zjzhai
 * Date: 13-10-30
 * Time: 下午12:04
 * To change this template use File | Settings | File Templates.
 */
public class Hello extends  HttpServlet {

    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException
    {
            doPost(req,resp);


    }
    @Override
    public void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException
    {
        resp.getWriter().println("<h2>hello</h2>");
        resp.addCookie(new Cookie("name","zjzhai"));
    }
}
